<?php

class Default_NumbersController extends Zend_Controller_Action
{

    public function init()
    {
        if($this->_request->isXmlHttpRequest()){
        	$this->_helper->layout()->disableLayout();
		}
    }

    public function indexAction()
    {
        
    }

    public function getProgressAction()
    {
        // action body
    }

    public function reservateNumberAction()
    {
        // action body
    }

    public function getNumbersStatusAction()
    {
        // action body
    }

    public function rejectNumbersAction()
    {
        // action body
    }

    public function getDataTableByNumberRangeAction()
    {
        $range = $this->_request->getParam('range');

		$numbersObject = Doctrine_Core::getTable('Default_Model_Numbers');
		$numbers = array('ranges' => null );
		$range_top = $range[1];
		$range_bot = $range[0];
		$demege = ($range_top-$range_bot)/50;
		for($i=1; $i<51; $i++){
			$numbers['ranges'][] = array('range_bot'=>$range_top-$demege,'range_top'=>$range_top, 'count'=>$numbersObject->getRangeInfo($range_bot, $range_top));
			$range_top -= $demege;
			$range_bot = $range_top-$demege;
		}
		
		$this->view->numbers = $numbers;
		
    }

    public function checkAvailableAction()
    {
    	$dig = $this->_request->getParam('dig');
		$dig = 7 - $dig; //бля мэджик 
    	$number = $this->_request->getParam('number');
		$nums = array(mt_rand(0, 9), mt_rand(0, 9), mt_rand(0, 9));
        $this->view->response = json_encode(array('digOrder'=>$dig, 'nums'=>$nums));
    }


}



